﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PBDesk.Utilities;

namespace CMS.PBDesk.Framework.Web
{
    public static class CommonHelper
    {
        public static string GetLoginProviderImage(string loginProvider)
        {
            string imageUrl = string.Empty;
            string imageName = string.Empty;
            if (loginProvider.IsNotNullAndNotEmpty())
            {
                imageUrl = @"/media/PBDesk/social/{0}";
                
                switch (loginProvider.ToLower())
                {
                    case "twitter":
                        {
                            imageName = "twitter_35.png";
                            break;
                        }
                    case "facebook":
                        {
                            imageName = "facebook_35.png";
                            break;
                        }
                    case "yahoo":
                        {
                            imageName = "yahoo_35.png";
                            break;
                        }
                    case "google":
                        {
                            imageName = "google_35.png";
                            break;
                        }
                    case "linkedin":
                        {
                            imageName = "linkedin_35.png";
                            break;
                        }
                    case "aol":
                        {
                            imageName = "aol_35.png";
                            break;
                        }
                    case "orkut":
                        {
                            imageName = "orkut_35.png";
                            break;
                        }                    
                }
                if (imageName.IsNotNullAndNotEmpty())
                {
                    imageUrl = string.Format(imageUrl, imageName);
                }

            }
            return imageUrl;
        }

        public static string GetDefailtProfilePicUrl()
        {
            return @"/media/PBDesk/social/default-profile-image50.gif";
        }

        public static bool IsValidUserName(string userName)
        {
            if (userName.IsNotNullAndNotEmpty() && StringUtils.IsValidEMailID(userName))
                return true;
            else
                return false;
        }

        public static string GetDisplayName(string fName, string lName, string nickName, string email)
        {
            string displayName = string.Empty;
            if (fName.IsNotNullAndNotEmpty())
                displayName = fName + " ";
            if (lName.IsNotNullAndNotEmpty())
                displayName += lName + " ";
            if (displayName.IsNullOrEmpty() && nickName.IsNotNullAndNotEmpty())
                displayName = nickName;
            if (displayName.IsNullOrEmpty() && email.IsNotNullAndNotEmpty())
                displayName = email;
            return displayName;
        }
    }
}
